package cn.boy.web.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.boy.service.DormitoryService;
import cn.boy.service.DormitoryServiceFactory;
import cn.boy.utils.Util;

public class RankDormitoryServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		
		String no_prex = request.getParameter("no_prex");
		String date = request.getParameter("date");
		
		if(!Util.isEmpty(no_prex) && !Util.isEmpty(date)){
			DormitoryServiceFactory instance = DormitoryServiceFactory.getInstance();
			DormitoryService service = instance.getDormitoryService();
			String json = service.rankDormitory(no_prex, date);
			System.out.println("rank dormitory---->>"+ json);
			response.getOutputStream().write(json.getBytes("UTF-8"));
		}
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
